package com.example.myapplication.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.myapplication.R;

public class ButtonView extends RelativeLayout {

    private TextView tvOn;
    private TextView tvOff;
    private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.btn_item, this);
        tvOn = findViewById(R.id.on);
        tvOff = findViewById(R.id.off);
    }

    public ButtonView(Context context) {
        super(context);
        init();
    }



    public ButtonView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public void setText(String txt) {
        tvOn.setText(txt);
        tvOff.setText(txt);
    }
    public void setChecked(boolean isChecked)
    {
        if(isChecked) {
            tvOff.setVisibility(GONE);
            tvOn.setVisibility(VISIBLE);
        } else {
            tvOn.setVisibility(GONE);
            tvOff.setVisibility(VISIBLE);
        }
    }
}
